import request from "@/utils/request";

/* 模型管理-分页查询 */
export function queryModelPage(params) {
  return request({
    url: "/management-admin/model/queryModelPage",
    method: "post",
    data: params,
  });
}

/* 模型管理-新增  弃*/
export function insertModel(data) {
  return request({
    url: "/management-admin/model/insertModel",
    method: "post",
    data,
  });
}

/* 模型管理-查询详情 */
export function getModelInfo(params) {
  return request({
    url: "/management-admin/model/getModelInfo",
    method: "get",
    params,
  });
}

/* 模型管理-修改 */
export function updateModel(data) {
  return request({
    url: "/management-admin/model/updateModel",
    method: "post",
    data,
  });
}

/* 模型管理-删除 */
export function deleteModel(id) {
  return request({
    url: `/management-admin/model/deleteModel?id=${id}`,
    method: "post",
  });
}

/* -------------------------------------- */

/* 模型分类-查询 */
export function queryModelDictPage(params) {
  return request({
    url: `/management-admin/dict/queryModelDictPage`,
    method: "post",
    data: params,
  });
}

/* 模型分类-新增 */
export function insertModelType(data) {
  return request({
    url: `/management-admin/dict/insertModelType`,
    method: "post",
    data,
  });
}

/* 模型分类-编辑 */
export function updateModelType(data) {
  return request({
    url: `/management-admin/dict/updateModelType`,
    method: "post",
    data,
  });
}

/* 模型分类-删除 */
export function deleteModelType(data) {
  return request({
    url: `/management-admin/dict/deleteModelType`,
    method: "post",
    data,
  });
}

/* 模型分类-导入 */
export function importModelDict(file) {
  const data = new FormData();
  data.append("file", file);
  return request({
    url: `/management-admin/dict/importModelDict`,
    method: "post",
    data,
  });
}

/* 模型分类-下载模板 */
export function downModelDict() {
  return request({
    url: `/management-admin/dict/downModelDict`,
    method: "get",
    responseType: "blob",
  });
}

/* 获取专业接口 */
export function queryModelFirst() {
  return request({
    url: `/management-admin/dict/queryModelFirst`,
    method: "get",
  });
}

/* 批量编辑 */
export function updateModelTypeBatch(data) {
  return request({
    url: `/management-admin/dict/updateModelTypeBatch`,
    method: "post",
    data,
  });
}

/* 通过ParentId获取专业接口 */
export function queryModelByParentId(parentId) {
  return request({
    url: "/business/dict/queryModelByParentId?parentId=" + parentId,
    method: "get",
  });
}

/* 获取大小类接口 */
export function queryBigSmallType(type) {
  return request({
    url:
      "/management-admin/model/queryDictByDictType?dictType=" +
      type +
      "&tenantCode=10001",
    method: "get",
  });
}

/* 获取省市接口 */
export function queryProvince() {
  return request({
    url: `/management-admin/dict/city/getCity`,
    method: "get",
  });
}

// 构件管理页面

/**
 *
 * 获取构件管理列表
 */
export function queryBypageRequest(data) {
  return request({
    url: `/management-admin/model/queryPage`,
    method: "post",
    data,
  });
}

/**
 *
 * 审批操作
 */
export function editByIdRequest(data) {
  return request({
    url: `/management-admin/model/edit`,
    method: "post",
    data,
  });
}

/**
 *
 * 获取详情数据
 */
// export function getDeteilByIdRequest(data) {
//   return request({
//     url: `/management-admin/resourceProduct/info?id=${data}`,
//     method: "get",
//   });
// }

/**
 *
 * 根据id获取图片
 */
export function getDeteilImgByIdRequest(data) {
  return request({
    url: `/management-admin/file/downloadFile?fileId=${data}`,
    method: "get",
    responseType: "blob",
  });
}

//模型分类页面

//获取产品分类树结构
export function getDickAllTreeListRequest(params) {
  return request({
    url: "/management-admin/dict/queryAllList",
    method: "get",
    params,
  });
}

/**
 * 模型新增表单
 */

/* 上传文件 */
export function uploadFileRequest(data) {
  return request({
    url: "/management-admin/model/insertModel",
    method: "post",
    data,
  });
}

//检查上传状态  0 正在进行中 1 成功 2失败 3 失效
export function checkUploadStatusRequest(params) {
  return request({
    url: "/management-admin/model/fileStatus",
    method: "get",
    params,
  });
}

//获取模型详情  用于数据回显
export function getModelDetailByIdRequest(params) {
  return request({
    url: `/management-admin/model/getModelInfo`,
    method: "get",
    params,
  });
}

//更新模型
export function changeFileRequest(data) {
  return request({
    url: "/management-admin/model/updateModel",
    method: "post",
    data,
  });
}

//模型类型字典
export function getModelTypeListRequest(data) {
  return request({
    url: "/management-admin/dict/resoure",
    method: "post",
    data,
  });
}

//获取编码
export function getCodeRequest(params) {
  return request({
    url: "/management-admin/dict/autoCode",
    method: "get",
    params,
  });
}

//新增 保存模型
export function saveModelRequest(data) {
  return request({
    url: "/management-admin/model/save",
    method: "post",
    data,
  });
}
// 获取详情 byid
export function getModelDetailById(id) {
  return request({
    url: `/management-admin/model/detail?id=${id}`,
    method: "get",
  });
}

//添加模型分类到 领域/专题
export function addModelToDomainOrTopic(data) {
  return request({
    url: "/management-admin/model/addClassfiyOne",
    method: "post",
    data,
  });
}

// 审核模型
export function editModelRequest(data) {
  return request({
    url: "/management-admin/model/edit",
    method: "post",
    data,
  });
}

//批量上传文件
export function uploadGrupFileRequest(data) {
  return request({
    url: "/management-admin/model/initModelByWeb",
    method: "post",
    headers: {
      timeout: 50000000,
    },
    data: data,
  });
}
